<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Prodect extends CI_Controller {
	public function __construct(){
		parent::__construct();
		$this->load->model('Prodect_model');
		$this->load->model('Article_model');
		$this->load->model('Prodect_catalog_model');
		$this->load->model('Prodect_img_model');
	}
	public function detail($id)
	{	
		$data=array(
			"prodect"=>$this->Prodect_model->get_one($id),
			"prodect_img"=>$this->Prodect_img_model->get_by_prodect_id($id)
			);		
		$this->load->view('prodect_detail',$data);
	}
	public function lists($cata_id)
	{	
		$catalog=$this->Prodect_catalog_model->get_one_pc($cata_id);
		if($catalog->parent_id==0){
			$catalogs=$this->Prodect_catalog_model->get_child_pc($cata_id);
			redirect('prodect/lists/'.$catalogs[0]->id);
		};
		$child_catalog=$this->Prodect_catalog_model->get_child_pc($cata_id);
		$where=array($catalog->id);
		foreach ($child_catalog as $c) {
			$where[]=$c->id;
		};
		
		$brand_id=$this->input->get("brand");
		
		$data=array(
				"parent_catalog"=>$this->Prodect_catalog_model->get_one_pc($catalog->parent_id),
				"child_catalog"=>$this->Prodect_catalog_model->get_child_pc($catalog->parent_id),
				"catalog"=>$catalog,
				"prodect_son"=>$this->Prodect_model->get_by_catalogs_id($where,$brand_id),
				"prodect_brand"=>$this->Prodect_model->get_brand_by_catalogs_id($cata_id)
			);
		$this->load->view('prodect_lists',$data);
	}
}